#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    int n;
    cin >> s >> n;
    int count = 0, maxcount = 0;
    int begin = 0;
    for (int left = 0, right = 0; right < s.size(); right++)
    {
        if (s[right] == 'C' || s[right] == 'G') count++;
        while (right - left + 1 > n)
        {
            if (s[left] == 'C' || s[left] == 'G') count--;
            left++;
        }
        if (right - left + 1 == n)
        {
            if (count > maxcount)
            {
                begin = left;
                maxcount = count;
            }
        }
    }

    cout << s.substr(begin, n) << endl;
}